package TUILayer;

public class MainMenuUI
{

    private AddressBookUI addressBookUI;
    private DVDUI dvdUI;
    private LoanUI loanUI;
    private InputParser inputParser;

    public MainMenuUI()
    {
        inputParser = new InputParser();
        addressBookUI = new AddressBookUI(inputParser);  
        dvdUI = new DVDUI(inputParser);
        loanUI = new LoanUI(inputParser);
        start();
    }

    public void start()
    {
        boolean exit=false;
        while (!exit)
        {
            int choise = inputParser.getInt("\f *** MainMenu ***\n\n1. AddressBook\n2. DVDs\n3. Loan\n4. Close\n\nMake your choise: ");
            if(choise == 1)
            {
                addressBookUI.start();
            }
            else if(choise == 2)
            {
                dvdUI.start();
            }
            else if(choise == 3)
            {
                loanUI.start();
            }
            else if(choise == 4)
            {
                exit = true;
                writeEnd();
            }
        }
    }

    private void writeEnd()
    {
        System.out.println("\f *** MainMenu ***");
        System.out.println("\nThe System is shuting down");
        try
        {
        	Thread.sleep(700);
        }
        catch(InterruptedException e)
        {
        	
        }
        System.exit(1);
    }

}
